/**
 * Created by xwj on 2017/9/1.
 */
public class Util {

    public static double clip(double val) {
        while (val > 1) val = val - 1;
        while (val < 0) val = val + 1;
        return val;
    }


    public static int clip(int val, int low, int high) {
        if (val < low) val = high - (low - val);
        if (val >= high) val = low + (val - high);
        return val;
    }
}
